package com.demo.mapper;

import com.demo.dto.CoursePageQueryDTO;
import com.demo.dto.DepartmentDTO;
import com.demo.dto.DepartmentPageQueryDTO;
import com.demo.pojo.Department;
import com.demo.vo.CourseVO;
import com.demo.vo.DepartmentVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DepartmentMapper {

    //新增学院信息
    @Insert("insert into sys_department(depID,depName) values (#{depID},#{depName})")
    void addDepartment(Department department);

    @Select("<script>" +
            "SELECT d.* " +
            "FROM sys_department d " +
            "WHERE 1=1 " +
            "<if test='depName != null and depName.trim() != \"\"'> " +
            "AND d.depName LIKE CONCAT('%', #{depName}, '%') " +
            "</if> " +
            "<if test='depID != null and depID.trim() != \"\"'> " +
            "AND d.depID = #{depID} " +
            "</if> " +
            "ORDER BY d.depID " +
            "</script>")
    Page<DepartmentVO> pageQuery(DepartmentPageQueryDTO departmentPageQueryDTO);

    //删除二级学院信息
    @Delete("delete from sys_department where depID=#{depID}")
    void delete(String depID);

    //修改二级学院信息
    @Update("update sys_department set depID=#{depID},depName=#{depName} where depID=#{depID}")
    void update(DepartmentDTO departmentDTO);
}
